"""
@Time : 2021/9/16 14:53 
@Author : 常雷
@File : t_31进制转换62进制.py 
@Software: PyCharm
"""
'''
写一个base62encode函数，计算62进制
即: 0123456789ABCD.. .Zabcd...z(10个数字，26个大写字母，26个小写字母)
base62encode(1) = 1
base62encode(61) = z
base62encode(62) = 10
'''

def base62encode(n):
    import string
    lst = []
    s = string.digits + string.ascii_uppercase + string.ascii_lowercase
    # print(s)  # 数字加大写字母加小写字母
    while n > 0:
        lst.append(s[n % 62])
        n //= 62
    return "".join(lst[::-1])


print(base62encode(6))
print(base62encode(66))
print(base62encode(666))
print(base62encode(666))
print(base62encode(6666))
print(base62encode(66666))
print(base62encode(666666))